﻿/**
 *	(C) 2014 Yuanjj
 *
 *	define error code and macro for building error code
 *
 *	histroy
 * 		2014-06-25	Yuanjj		-	create
 */

#ifndef _ERRORCODE_H_
#define _ERRORCODE_H_

enum ENUM_ERR
{
    PEM_OK					= 0x0,		// OK
    PEM_USER_NOACCIVE,					// user has not been acctived yet

    PEM_OPT_EXEPATH			= 0x11,		// load exe path failed
    PEM_OPT_FILEOPEN,					// option file ("./pem_sys.xml") open failed

    PEM_MYSQL_CONNECT		= 0x21,		// mysql connect failed
    PEM_MYSQL_QUERY,					// mysql query failed
    PEM_MYSQL_RESULT,					// get query result failed
    PEM_MYSQL_CHARSET,					// set character set failed

    PEM_NET_LOAD			= 0x31,		// net share library load failed

    PEM_QUEUE_EXIST 		= 0x41,		// the queue is alread exist
    PEM_QUEUE_CREATE,					// create queue failed
    PEM_QUEUE_PARAMS,					// the params are not correct
    PEM_QUEUE_FULL,						// the queue is full
    PEM_QUEUE_EMPTY,					// the queue is empty

    PEM_TUNNEL_TYPE			= 0x51,		// the tunnel type is not correct
    PEM_TUNNEL_BUFSIZE,					// the buffer size is not enough

    PEM_THREAD_CREATE		= 0x61,		// the thread create failed

    PEM_PROTOCAL_MAGIC		= 0x71,		// the protocal magic number is not correct
    PEM_PROTOCAL_SIZE,					// the protocal size is not enough
    PEM_PROTOCAL_MAIN,					// protocal main is not correct
    PEM_PROTOCAL_UNKNOW,				// unknow protocal second
};

#define		BUILD_ERRORCODE( _sys_, _pem_ )	\
                ((((0x8000)|(_sys_))<<16) | (((0x8000)|(_pem_))&0xFFFF))

#define		GET_SYS_ERROR( _err_ ) (((_err_)>>16) & 0x7FFF)
#define		GET_PEM_ERROR( _err_ ) ((_err_) & 0x7FFF)

#endif // _ERRORCODE_H_
